// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   ParagrahpElement.java

package app;

import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import ui.BrowserCanvas;
import ui.Element;

// Referenced classes of package app:
//            Utils

public class ParagrahpElement extends Element
{

    ParagrahpElement(String content, int x, int y, int width, int style, int color)
    {
        super(x, y);
        kondisi = false;
        kondisi2 = false;
        super.width = width;
        if(style == 2)
        {
            //this.color = 0xbf0b07;
            this.color = 0x0;
            font = (style & 1) != 1 ? BrowserCanvas.FONTSMALL : BrowserCanvas.FONTSMALLBOLD;
            header = true;
            kondisi = true;
        } else
        if(style == 3)
        {
            this.color = 0x0;
            font = (style & 1) != 1 ? BrowserCanvas.FONTSMALL : BrowserCanvas.FONTSMALL;
            header = true;
            kondisi = true;
        } else
        if(style == 4)
        {
            this.color = 0x0;
            font = (style & 1) != 1 ? BrowserCanvas.FONTSMALLITALIC : BrowserCanvas.FONTSMALLITALIC;
            header = true;
            kondisi2 = true;
        } else
        {
            this.color = 0x0;
            font = (style & 1) != 1 ? BrowserCanvas.FONTSMALL : BrowserCanvas.FONTSMALLBOLD;
            header = false;
        }
        texts = Utils.getArrayFitString(font, content, width, false, header);
        super.height = font.getHeight() * texts.length;
    }

    public void draw(Graphics g, int x, int y, int startY, int stopY, boolean selected)
    {
        g.setColor(color);
        g.setFont(font);
        y += super.top;
        int i;
        for(i = 0; i < texts.length && y < startY; i++)
            y += font.getHeight();

        g.setColor(color);
        for(; i < texts.length && y <= stopY; i++)
        {
            //g.drawString(texts[i], x + super.left, y, 20);
            g.drawString(texts[i], x + super.left, y, Graphics.TOP|Graphics.LEFT);
            y += font.getHeight();
        }

    }

    public static final int BOLD = 1;
    public static final int NORMAL = 0;
    public static final int SMALL = 0;
    public static final int BIG = 2;
    public static final int HEADER = 3;
    public static final int BAB = 4;
    private boolean kondisi;
    private boolean kondisi2;
    private boolean header;
    private String texts[];
    private Font font;
    private int color;
}
